<#assign base=request.contextPath>
<!DOCTYPE html> 
<html>
	<head>
		<title>${title}</title>
		<meta charset="utf-8">
		<#include "common/reference.ftl"/>
		<script type="text/javascript">

        //密码复杂要求：
        //    1、长度大于等于6
        //    2、密码必须是字母大写，字母小写，数字，特殊字符中任意三个组合。
		function checkPass(pass){
             if(s.length < 6){
                 return 0;
             }
         }
		<!--
			$(function(){
				$('.chosen-select').chosen();
                $('#companyId').chosen();
                $('#companyId').change(function(){
                    var companyId = $(this).val();
                    var companyName = $(this).find('option[value="'+companyId+'"]').text();
                    $('input[type="hidden"][name="companyName"]').val(companyName);
                });
                $('#companyName').trigger('change');
				
				$('#userName1').blur(function(){
					var userName = $(this).val();
					if(userName == null || userName.length < 1)
						return;
					$.ajax({
						url:'${base}/admin/checkUserName',
						type:'POST',
						data:{userId:'${model.userId}',userName:userName},
						dataType:'json',
						success:function(rst){
							if(rst.status != "OK"){
								bootbox.alert(rst.message);
								$('#userName').val('');
							}
						}
					});
				});

				$('form').validate({
					rules:{
						userName:{
							required:true,
							minlength:4,
							maxlength:50
						},
						trueName:{
							required:true,
							rangelength:[1,50]
						}
					},
					messages:{
						userName:{
							required:'用户名不能为空',
							minlength:'用户名长度不能小于4',
							maxlength:'用户名长度不能大于50'
						},
						trueName:{
							required:'真实姓名不能为空',
							rangelength:'真实姓名不能为空'
						}
					}
				});
			});
		//-->
		</script>
	</head>
	<body class="${configs["skinName"]}">
		<div class="page-content">
			<div class="row">
				<#include "common/breadcrumb.ftl">
				<div class="col-xs-12 col-sm-5">
					<div class="widget-box">
						<div class="widget-header header-color-blue2">
							<h5 class="lighter">
								<i class="fa fa-plus"></i>
								管理员用户
							</h5>
						</div>
						<div class="widget-body">
							<form role="form" class="form-horizontal" method="post" action="${base}/${form_action}">
								<div class="alert alert-warning">
									<strong>提示!</strong>
									用户名称和真实姓名不能为空<br/>

									用户密码必须满足以下规则：<br/>
									1、长度不小于6位；<br/>
									<!--2、必须以字母开头；<br/>
									3、必须包含特殊字符；<br/>
									4、必须包含数字
									-->
								</div>
								<input type="hidden" name="userId" id="userId" value="${model.userId}" >
								<div class="form-group">
									<label class="col-sm-3 control-label no-padding-right">
										用户名称
									</label>
									<div class="col-sm-9">
										<input type="text" name="userName" id="userName" placeholder="请输入用户名" value="${model.userName}">
									</div>
								</div>
								<div class="form-group">
									<label class="col-sm-3 control-label no-padding-right">
										真实姓名
									</label>
									<div class="col-sm-9">
										<input type="text" name="trueName" id="trueName" placeholder="请输入真实姓名" value="${model.trueName}">
									</div>
								</div>
								<div class="form-group">
									<label class="col-sm-3 control-label no-padding-right">
										用户密码
									</label>
									<div class="col-sm-9">
										<input type="password" name="password" id="password" placeholder="请输入登陆密码" value="">
									</div>
								</div>
								<div class="form-group">
									<label class="col-sm-3 control-label no-padding-right">
										是否启用
									</label>
									<div class="col-sm-9">
										<input class="ace ace-switch ace-switch-5" type="checkbox" name="enabled" <#if model == null || model.enabled>checked="checked"</#if>>
										<span class="lbl"></span>
									</div>
								</div>
								<div class="form-group">
									<label class="col-sm-3 control-label no-padding-right">
										设置角色
									</label>
									<div class="col-sm-9">
										<#if roles?exists && roles?size gt 0>
											<#list roles as role>
												<div class="radio no-padding-left" style="float:left;">
													<label class="control-label no-padding-right">
														<input class="ace" type="radio" name="roleId" value="${role.roleId}"<#if model.roleId == role.roleId >checked="checked" </#if> >
														<span class="lbl">${role.roleName}</span>
													</label>
												</div>
											</#list>
										</#if>
									</div>
								</div>
								<div class="form-group">
                                    <label class="col-sm-3 control-label no-padding-right">
                                        所属分公司
                                    </label>
                                    <div class="col-sm-6">
                                        <select id="companyId" name="companyId" class="chosen-select form-control"  data-placeholder="请选择所属分公司" <#if viewMode == "view">disabled</#if>>
                                            <option value="">请选择所属公司</option>
                                            <#if companyList?exists && companyList?size gt 0>
                                            <#list companyList as item>
                                            <option value="${item.companyId}"<#if model.companyId == item.companyId>selected</#if> >${item.ownerName}</option>
                                            </#list>
                                            </#if>
                                        </select>
                                        <input type="hidden" name="companyName" value="${model.companyName}">
                                    </div>
                                </div>
                                <!--
                                <div class="form-group">
                                    <label class="col-sm-3 control-label no-padding-right">
                                        设置地区
                                    </label>
                                    <div class="col-sm-9">
										<#if areas?exists && areas?size gt 0>
											<#list areas as area>
												<div class="radio no-padding-left" style="float:left;">
                                                    <label class="control-label no-padding-right">
                                                        <input class="ace" type="radio" name="areaId" value="${area.areaId}"<#if model.areaId == area.areaId >checked="checked" </#if> >
                                                        <span class="lbl">${area.areaName}</span>
                                                    </label>
                                                </div>
											</#list>
										</#if>
                                    </div>
                                </div>
                                -->
								<div class="clearfix form-actions">
									<div class="col-md-offset-3 col-md-9">
										<button id="btnSubmit" class="btn btn-info" type="submit">
											<i class="fa fa-check bigger-110"></i>
											提 交
										</button>
									</div>
								</div>
							</form>
						</div>
					</div>
				</div>
			</div>
		</div>
	</body>
</html>